package 贪心;

/**
 * @author TTDB
 * @create 2025/9/23
 */
public class maxProfit {
     public int maxProfit(int[] prices) {
        int profit = 0;
        int cost = Integer.MAX_VALUE;
        for (int price : prices) {
            cost = Math.min(cost, price);//最少开销
            profit = Math.max(profit, price - cost);
        }
        return profit;
    }
}
